<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2019/4/9
 * Time: 17:39
 * 研学统计
 */
namespace app\admin\controller;
use think\Db;
class Research  extends Base {

    public function index(){
        $res = array();
        $where['n_type'] = 1;
        $where['n_del'] = 1;
        //研学统计数量
        $count = Db::table('up_notice')->where($where)->count();
        //研学报名总数
        $count1 = Db::table('up_notice')->where($where)->sum('n_num');
        //研学已报名数量
        $count2 = Db::table('up_notice')->where($where)->sum('n_num_already');

        $where1['n_type'] = 1;
        $where1['n_del'] = 1;
        $n_id = Db::table('up_notice')->where($where1)->column('n_id');
        $n_id_a = implode(',',$n_id);
        $time2 =  date('Y-m-d 23:59:59');
        $time1 =  date('Y-m-d 00:00:01');
        $where2['st_n_id'] = array('IN',$n_id_a);
        $where2['st_time'] = array('between',array($time1,$time2));
        $count4 = Db::table('up_studies')->where($where2)->count();
        $res['count'] =$count;
        $res['count1'] =$count1 - $count2;
        $res['count2'] =$count4;
        $this->assign('res',$res);
        return $this->fetch();
    }
}